package com.dede.rxbase.comm;

import android.app.Activity;
import android.app.Application;
import android.os.Bundle;

import com.dede.rxbase.util.ActivityManager;
import com.dede.rxbase.util.BLog;

/**
 * @author hsh
 *         2018/1/18 14:35.
 */
public class ActivityLifecycle implements Application.ActivityLifecycleCallbacks {

    private ActivityLifecycle() {
    }

    private static ActivityLifecycle mInstance;

    public static ActivityLifecycle getInstance() {
        if (mInstance == null) {
            mInstance = new ActivityLifecycle();
        }
        return mInstance;
    }

    @Override
    public void onActivityCreated(Activity activity, Bundle savedInstanceState) {
        ActivityManager.onCreate(activity);
        BLog.log(activity, "onActivityCreated");
    }

    @Override
    public void onActivityStarted(Activity activity) {
        BLog.log(activity, "onActivityStarted");
    }

    @Override
    public void onActivityResumed(Activity activity) {
        BLog.log(activity, "onActivityResumed");
    }

    @Override
    public void onActivityPaused(Activity activity) {
        BLog.log(activity, "onActivityPaused");
    }

    @Override
    public void onActivityStopped(Activity activity) {
        BLog.log(activity, "onActivityStopped");
    }

    @Override
    public void onActivitySaveInstanceState(Activity activity, Bundle outState) {
        BLog.log(activity, "onActivitySaveInstanceState");
    }

    @Override
    public void onActivityDestroyed(Activity activity) {
        ActivityManager.onDestroy(activity);
        BLog.log(activity, "onActivityDestroyed");
    }
}
